package com.ad.pet.common.data.utils.ui;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

import com.ad.pet.App;


/**
 * Created by ems on 2017/2/27.
 */

public class ToastUtil {
    Context context;
    private Toast mMakeText;
    private Toast mCustomText;
    private static ToastUtil sToastUtil = new ToastUtil(App.getApp().getApplicationContext());

    public static ToastUtil getToastUtil() {
        return sToastUtil;

    }


    public ToastUtil(Context context) {
        this.context = context.getApplicationContext();
    }


    public void showShort(String msg) {
        if (mMakeText == null) {
            mMakeText = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
            mMakeText.setGravity(Gravity.CENTER, 0, 0);
        }
        mMakeText.setText(msg);
        mMakeText.show();
    }


    public void cancelToast() {
        if (mMakeText != null) {
            mMakeText.cancel();
            mMakeText = null;
        }
    }
}
